<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 基础模块（任务）数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\exception\LogicException;

use common\service\TaskAssignService;

use think\Request;

class TaskAssignController extends VerifyController
{
    private $taskAssignService;

    public function __construct()
    {
        parent::__construct();
        $this->taskAssignService = TaskAssignService::getInstance();
    }

    /**
     * 查询待分配的任务树
     * @param Request $request
     * @return \think\Response|void
     * @throws \Throwable
     */
    public function getAssignPopTaskTreeByEntityStepCategory(Request $request)
    {
        $param = $request->param();
        $entityIdList = $param['param']['entity_id_list'];
        $stepCategoryId = $param['param']['step_category_id'];
        try {
            $res = $this->taskAssignService->getAssignPopTaskTreeByEntityStepCategory($entityIdList, $stepCategoryId);
            return json(success_response('', $res));
        } catch (LogicException $e) {
            throw_strack_exception($e->getMessage(), $e->getCode());
        }
    }
}
